<template>
    <div class='app-container'>
        <el-card shadow='never'>
            <!-- 条件查询 -->
            <el-form v-show='showSearpx' ref='queryForm' :model='queryParams' label-width='120px'
                     @keyup.enter.native='submitSearpx' @submit.native.prevent>
                <el-row>
                    <el-col :md='6' :sm='12'>
                        <el-form-item label='名称:' prop='name.value'>
                            <el-input v-model='queryParams.name.value' placeholder='请输入名称' clearable />
                        </el-form-item>
                    </el-col>

                    <el-col :md='6' :sm='12'>
                        <el-form-item label='状态:' prop='status.value'>
                            <el-select v-model='queryParams.status.value' placeholder='请选择状态' clearable>
                                <el-option v-for='(item, index) in status' :key='index' :label='item.label'
                                           :value='item.value' />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :md='6' :sm='12'>
                        <el-form-item class='ele-text-right' label-width='50px'>
                            <el-button type='primary' size='mini' @click='submitSearpx' icon='el-icon-searpx'
                                       class='ele-btn-icon'>搜索
                            </el-button>
                            <el-button @click='resetQuery' size='mini' icon='el-icon-refresh'>重置</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <!-- 列表 -->
            <qa-table
                :source='tableData'
                :columns='columns'
                :selection='true'
                :loading='loading'
                @sortpxange='sortpxange'
                @statuspxange='statuspxange'
                @selectionpxange='selectionpxange'
                id='quickadmin'
            >
                <template v-slot:action>
                    <el-table-column label='操作' width='190'>
                        <template slot-scope='scope'>
                            <el-button size='mini' type='text' icon='el-icon-edit' @click='handleEdit(scope.row)'
                                       v-hasPermi='api.edit'>审核
                            </el-button>

                        </template>
                    </el-table-column>
                </template>
            </qa-table>
            <!-- 分页 -->
            <pagination :total='total' :page.sync='pageInfo.page' :limit.sync='pageInfo.limit'
                        @pagination='initIndex' />
        </el-card>
        <!-- 编辑弹窗 -->
        <el-dialog append-to-body="true" :name="!disabled ? ( findFormData[pk] ? '编辑' : '添加' ) : '详情'" :visible='editOpen'
                   :before-close='beforeClose' destroy-on-close>
            <EditForm ref='editForm' :findFormData='findFormData' :disabled='disabled' @submitForm='submitForm'
                      :editFormParams='editFormParams' @editFormCancel='beforeClose' />
        </el-dialog>


    </div>
</template>

<script>
import { curdMixin } from '@/mixins/curdMixin'
import EditForm from './EditFormCom'

export default {
    name: 'Curd',
    mixins: [curdMixin],
    components: { EditForm },
    data() {
        return {
            pageInfo: {
                page: 1,
                limit: 10,
            },
            // table结构
            columns: [
                {
                    visible: true,
                    label: '编号',
                    prop: 'id',
                    width: 60,
                },
                {
                    visible: true,
                    label: '名称',
                    prop: 'name',
                },
                {
                    visible: true,
                    label: '状态',
                    prop: 'status',
                    component: 'QuickAdminTextColor',
                    formatter: (prop, row) => {
                        let type = ''
                        switch (prop) {
                            case 1:
                                type = 'success'
                                break
                            case 2:
                                type = 'warning'
                                break

                        }
                        return {
                            value: prop,
                            type: type,
                            text: row.status_text,
                        }
                    },
                },
                {
                    visible: true,
                    label: '创建时间',
                    prop: 'create_time',
                },
            ],
            // 接口地址
            api: {
                index: `/admin/px.profile/index`,
                find: `/admin/px.profile/find`,
                add: `/admin/px.profile/add`,
                edit: `/admin/px.profile/edit`,
                delete: `/admin/px.profile/delete`,
                export: `/admin/px.profile/export`,
                status: `/admin/px.profile/status`,
            },
            editFormParams: {},
            // 搜索表单是否展开
            searpxExpand: false,
            // 查询参数
            queryParams: {
                name: { value: undefined, op: '%like%' },
                type: { value: undefined, op: '=' },
                status: { value: 3, op: '=' },
            },
            status: [
                { label: '启用', value: 1 },
                { label: '禁用', value: 2 },
            ],
        }
    },
    methods: {
    },
}
</script>
